//
//  AppRoute.swift
//  应用路由配置
//
//  Created by chen on 2025/5/2.
//

import Foundation

enum AppRoute: Hashable {
    
    case contentView(selectTab: TabEnum)
    case detailView(id: Int64)
    case hotView
    case searchView
    case searchResult(keyWord: String)
    case loginView
    case registerView
    
    func hash(into hasher: inout Hasher) {
        switch self {
        case .contentView(let selectTab):
            hasher.combine("contentView")
            hasher.combine(selectTab)
        case .detailView(let id):
            hasher.combine("detailView")
            hasher.combine(id)
        case .hotView:
            hasher.combine("hotView")
        case .searchView:
            hasher.combine("searchView")
        case .searchResult(let keyWord):
            hasher.combine("searchResult")
            hasher.combine(keyWord)
        case .loginView:
            hasher.combine("loginView")
        case .registerView:
            hasher.combine("registerView")
        }
    }
    
    static func == (lhs: AppRoute, rhs: AppRoute) -> Bool {
        switch (lhs, rhs) {
        case (.contentView(let selectTab1), .contentView(let selectTab2)):
            return selectTab1 == selectTab2
        case (.detailView(let id1), .detailView(let id2)):
            return id1 == id2
        case (.hotView, .hotView):
            return true
        case (.searchView, .searchView):
            return true
        case (.searchResult(let keyWord1), .searchResult(let keyWord2)):
            return keyWord1 == keyWord2
        case (.loginView, .loginView):
            return true
        case (.registerView, .registerView):
            return true
        default:
            return false
        }
    }
}
